<!DOCTYPE html>
<!--[if IE 9]>         <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="en">
	<!--<![endif]-->

	<head>
		<meta charset="utf-8">

		<title>问卷详情——</title>

		<meta name="description" content="AppUI is a Web App Bootstrap Admin Template created by pixelcave and published on Themeforest">
		<meta name="author" content="pixelcave">
		<meta name="robots" content="noindex, nofollow">

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<!-- Icons -->
		<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
		<link rel="shortcut icon" href="img/favicon.png">
		<link rel="apple-touch-icon" href="img/icon57.png" sizes="57x57">
		<link rel="apple-touch-icon" href="img/icon72.png" sizes="72x72">
		<link rel="apple-touch-icon" href="img/icon76.png" sizes="76x76">
		<link rel="apple-touch-icon" href="img/icon114.png" sizes="114x114">
		<link rel="apple-touch-icon" href="img/icon120.png" sizes="120x120">
		<link rel="apple-touch-icon" href="img/icon144.png" sizes="144x144">
		<link rel="apple-touch-icon" href="img/icon152.png" sizes="152x152">
		<link rel="apple-touch-icon" href="img/icon180.png" sizes="180x180">
		<!-- END Icons -->

		<!-- Stylesheets -->
		<!-- Bootstrap is included in its original form, unaltered -->
		<link rel="stylesheet" href="css/bootstrap.min.css">

		<!-- Related styles of various icon packs and plugins -->
		<link rel="stylesheet" href="css/plugins.css">
		<link rel="stylesheet" href="css/page.css" />
		<!-- The main stylesheet of this template. All Bootstrap overwrites are defined in here -->
		<link rel="stylesheet" href="css/main.css">
		<link  href="css/laypage.css" />
		<!-- Include a specific file here from css/themes/ folder to alter the default theme of the template -->

		<!-- The themes stylesheet of this template (for using specific theme color in individual elements - must included last) -->
		<link rel="stylesheet" href="css/themes/amethyst.css">
		<!-- END Stylesheets -->
		<link rel="stylesheet" href="css/laypage.css">
		<!-- Modernizr (browser feature detection library) -->
		<script src="js/vendor/modernizr-3.3.1.min.js"></script>
	</head>

	<body>
		<!-- Page Wrapper -->
		<!-- In the PHP version you can set the following options from inc/config file -->
		<!--
            Available classes:

            'page-loading'      enables page preloader
        -->
		<div id="page-wrapper" class="page-loading">
			<!-- Preloader -->
			<!-- Preloader functionality (initialized in js/app.js) - pageLoading() -->
			<!-- Used only if page preloader enabled from inc/config (PHP version) or the class 'page-loading' is added in #page-wrapper element (HTML version) -->
			<div class="preloader">
				<div class="inner">
					<!-- Animation spinner for all modern browsers -->
					<div class="preloader-spinner themed-background hidden-lt-ie10"></div>

					<!-- Text for IE9 -->
					<h3 class="text-primary visible-lt-ie10"><strong>Loading..</strong></h3>
				</div>
			</div>
			<!-- END Preloader -->

			<!-- Page Container -->
			<!-- In the PHP version you can set the following options from inc/config file -->
			<!--
                Available #page-container classes:

                'sidebar-light'                                 for a light main sidebar (You can add it along with any other class)

                'sidebar-visible-lg-mini'                       main sidebar condensed - Mini Navigation (> 991px)
                'sidebar-visible-lg-full'                       main sidebar full - Full Navigation (> 991px)

                'sidebar-alt-visible-lg'                        alternative sidebar visible by default (> 991px) (You can add it along with any other class)

                'header-fixed-top'                              has to be added only if the class 'navbar-fixed-top' was added on header.navbar
                'header-fixed-bottom'                           has to be added only if the class 'navbar-fixed-bottom' was added on header.navbar

                'fixed-width'                                   for a fixed width layout (can only be used with a static header/main sidebar layout)

                'enable-cookies'                                enables cookies for remembering active color theme when changed from the sidebar links (You can add it along with any other class)
            -->
			<div id="page-container" class="header-fixed-top">
				<!-- Main Container -->
				<div id="main-container">
					<!-- Header -->
					<!-- In the PHP version you can set the following options from inc/config file -->
					<!--
                        Available header.navbar classes:

                        'navbar-default'            for the default light header
                        'navbar-inverse'            for an alternative dark header

                        'navbar-fixed-top'          for a top fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar())
                            'header-fixed-top'      has to be added on #page-container only if the class 'navbar-fixed-top' was added

                        'navbar-fixed-bottom'       for a bottom fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar()))
                            'header-fixed-bottom'   has to be added on #page-container only if the class 'navbar-fixed-bottom' was added
                    -->
					<header class="navbar navbar-inverse navbar-fixed-top">
						<!-- Left Header Navigation -->
						<ul class="nav navbar-nav-custom">
							<!-- Header Link -->
							<li class="hidden-xs animation-fadeInQuick">
								<a href="survey.html"><strong><big>问道</big></strong></a>
							</li>
							<!-- END Header Link -->
						</ul>
						<!-- END Left Header Navigation -->

						<!-- Right Header Navigation -->
						<ul class="nav navbar-nav-custom pull-right">
							<!-- User Dropdown -->
							<li class="dropdown">
								<span> </span>
								<a onclick="logout()"  class="dropdown-toggle" data-toggle="dropdown">
									注销
								</a>
							</li> 
							<!-- END User Dropdown -->
						</ul>
						<!-- END Right Header Navigation -->
					</header>
					<!-- END Header -->

					<!-- Page content -->
					<div id="page-content">
						<!-- Blank Header -->
						<div class="content-header">
							<div class="row">
								<div class="col-sm-12">
									<div class="header-section" style="width: 100%;">
										<h1 class="inline">调查详情</h1>
										<h5 class="inline">-<a href="#modal-chgTitle" data-toggle="modal" id="survey-name"></a></h5>
										<span class="label" style="margin-left: 40px;color: black;" id="survey-state">已提交</span>
										<a class="inline" style="margin-left: 20px;" data-toggle="modal" href="#modal-chgTime" id="survey-period">周期：2018.09.18~2018.10.18</a>
										<span class="pull-right">
											<span id="btn-outer">
												
											</span>
											<!--<button class="btn" id="statebtn" type="button" onclick="chgState()">运行</button>-->
											<a class="btn btn-danger" data-toggle = "modal" href="#modal-delete">删除</a>
										</span>
									</div>
								</div>
							</div>
						</div>
						<!-- END Blank Header -->

						<div class="row">
							<div class="col-sm-10 col-sm-offset-1 col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
								<div class="block full">
									<div class="block-title">
										<h2>绑定问卷</h2>
									</div>
									<div class="block full">
										<form action="" class="form-horizontal">
											<div class="form-group">
												<div class="col-md-12">
													<p class="well text-center">
														<a href="" id="survey-title"></a>
														<span class="text-center" style="float: right;padding: 0;margin-top: -.5%;">
															<button class="btn btn-primary" type="button" onclick="preview(this.name)" id="survey-preview" >预览</button>
														</span>
													</p>
												</div>
												<!--<div class="col-md-4 text-right">
													<button class="btn btn-primary">预览</button>
												</div>-->
											</div>
										</form>
									</div>
								</div>
								<div class="block full">
									<div class="block-title">
										<h2>绑定部门</h2>
									</div>
									<p class="well text-center">
										<span class="text-center" style="text-align: center;" id="department">
											
										</span>
									</p>
								</div>
								<div class="block full">
									<div class="block-title">
										<h2>人员详情</h2>
									</div>
									<div id="member_num" style="border: 1px solid #dae0e8; padding: 6px;"><span style='padding: 17px;display: inline;'>调查人员</span><button type='button' class='btn btn-effect-ripple btn-primary'  onclick='getImport()' style='margin-left: 85%;font-size: .7px;'>添加人员组</button></div>
									<div class="block full hidden" id="member-type">
										
									</div>
									<div class="block full hidden" id="select_opt">
										<form action="" class="form-horizontal">
											<div class="form-group">
												<div class="col-md-8 col-md-offset-2">
													<select id="val-surveybinding" name="val-surveybinding" class="form-control">
														
													</select>
												</div>
											</div>
										</form>
									</div>
									<div class="block full "  style="padding: 10px;">
										<a style="background: #4d7d98;border: none;" class="btn btn-success mb-4 hidden" id="sending_togo" onclick="sendgoto()">添加到通知池</a>
										<input type="text" id="input-search-survey" name="example-input1-group2" class="form-control hidden"  placeholder="搜   索" style="text-align: center;float: right;width: 15%;";>
										<!--<div class="table-responsive">-->
										 <table class="table table-bordered table-striped hidden" id="example-datatable">
												<thead>
													<tr>
														<th style="height: 40%;width: 8%; text-align: center; font-size: 2rem;"><input id="clickall" style="width: 20px;height: 20px;" type="checkbox"/></th>
										 	 	 		<th style="height: 40%;width: 10%; font-size: 2rem;">工号</th>
										 	 	 		<th style="height: 40%;width: 10%; font-size: 2rem;">姓名</th>
										 	 	 		<th style="height: 40%;width:30%;font-size: 2rem;">部门</th>
										 	 	 		<th style="height: 40%;width:10%;font-size: 2rem;">手机号码</th>
										 	 	 		<th style="height: 40%;width: 10%;font-size: 2rem;">类型</th>
										 	 	 		<th style="height: 40%;width:10%;font-size: 2rem;">完成情况</th>
										 	 	 		<th style="height: 40%;font-size: 2rem;">短信</th>
										 	 	 		</tr>
												</thead>
												<tbody id="tab_list"  class="table table-bordered table-striped"></tbody>
											
											<!-- update Modal -->
											<div id="modal-update" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
												<div class="modal-dialog">
													<div class="modal-content">
														<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
															<h3 class="modal-title"><strong>提示</strong></h3>
														</div>
														<div class="modal-body">
															是否更新该问卷？
														</div>
														<div class="modal-footer">
															<button type="button" class="btn btn-effect-ripple btn-primary">确定</button>
															<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
														</div>
													</div>
												</div>
											</div>
											<!-- END update Modal -->

											<!-- upload Modal -->
											<div id="modal-upload" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
												<div class="modal-dialog">
													<div class="modal-content">
														<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
															<h3 class="modal-title"><strong>上传问卷</strong></h3>
														</div>
														<div class="modal-body">
															<form action="page_app_media.html" class="dropzone"></form>
														</div>
														<div class="modal-footer">
															<button type="button" class="btn btn-effect-ripple btn-primary">确定</button>
															<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
														</div>
													</div>
												</div>
											</div>
										</table>
										<div id="layui" style="font-size: 2 rem;padding: 0 0 4% 0;"></div>	 	
											<!-- END upload Modal -->
										</div>
										<!--</div>-->
									</div>
							</div>
						</div>
						<!-- chgTitle Modal -->
						<div id="modal-chgTitle" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>-->
										<h3 class="modal-title"><strong>请输入新的问卷名称</strong></h3>
									</div>
									<div class="modal-body">
										<!--<h4>请输入新的问卷名称</h3>-->
										<input type="text" name="newTitle" id="newTitle" value="" class="form-control"/>
										<div id='quesnote' style='margin-left:1%;margin-top:2%;color:red'></div>
									</div>
									<div class="modal-footer">
										<button type="button" onclick="submit()" class="btn btn-effect-ripple btn-primary">确定</button>
										<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
									</div>
								</div>
							</div>
						</div>
						<!-- END chgTitle Modal -->
						<!-- delete Modal -->
								<div id="modal-delete" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												是否删除该调查？
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="deleteSurvey()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								<!-- END delete Modal -->
								<!-- notStart Modal -->
								<div id="modal-notStart" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												该调查处在未开始状态，是否更改调查周期，运行此调查？
												<div class="row" style="margin: 4% 0 0 0;">
													<div class="col-md-12">
															<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
																<input type="text" id="notStart-startTime" name="example-daterange1" class="form-control " placeholder="起始日期" style="width: 40%;display: inline;">
															</div>
															<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
																<input type="text" id="notStart-endTime" name="example-daterange2" class="form-control" placeholder="终止日期" style="width: 40%;display: inline;" >
															</div>
								
													</div>
												</div>
												<div id="quesnote1" class="note" style='color:red;width:fit-content;margin-top: 2%;margin-left: 2.4%;'></div>
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="chgState1()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								<!-- END notStart Modal -->
								<!-- ended Modal -->
								<div id="modal-ended" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												该调查处在已结束状态，是否更改调查周期，运行此调查？
												<div class="row"   style="margin: 4% 0 0 0;">
													<div class="col-md-12">
														<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
															<input type="text" id="ended-startTime" name="example-daterange1" class="form-control " placeholder="起始日期" style="width: 40%;">
															</div>
															<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
															<input type="text" id="ended-endTime" name="example-daterange2" class="form-control" placeholder="终止日期" style="width: 40%;">
															</div>
														</div>
												</div>
													<div id="quesnote2" class="note" style='color:red;width:fit-content;margin-top: 2%;margin-left: 2.4%;'></div>
											
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="chgState2()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								<!-- END ended Modal -->
								<!-- import Modal -->
								<div id="modal-import" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												导入
											</div>
											<div class="modal-body">
												<div class="table-responsive">
													<table id="import-datatable" class="table table-striped table-bordered table-vcenter table-hover" style="width: 100%;">
														<!--<thead>
														<tr>
															<th class="text-center">选择</th>
															<th class="text-center">调查小组</th>
														</tr>
													</thead>-->
													</table>
												</div>
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" id="detail_number" onclick="bindPeople()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal" id="import-close">取消</button>
											</div>
										</div>
									</div>
								</div>
								<!-- END import Modal -->
								<div id="modal-note" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												清空调查绑定人员组后之前所提交的答卷将会失效，是否清空绑定人员？
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="deletemember2()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								<div id="modal-fnote" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body" id="deletenode">
												 
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary"data-dismiss="modal">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								
								<div id="modal-sendmsg" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body" id="sendtogo">
												 所选人员已成功加入通知池
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary"data-dismiss="modal" onclick="fresh()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" onclick="goto_send()" data-dismiss="modal">前往 查看</button>
											</div>
										</div>
									</div>
								</div>
								<div id="modal-bindpeople" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body" id="fail_msg">
												 
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary"data-dismiss="modal">确定</button>
											</div>
										</div>
									</div>
								</div>
								
								<div id="modal-chgTime" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												请选择更改后的调查周期
												<div class="row" style="margin: 4% 0 0 0;">
													<div class="col-md-12">
															<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
																<input type="text" id="setTime-startTime" name="example-daterange1" class="form-control " placeholder="起始日期"  style="width: 40%;">
															</div>
															<div class="input-group input-daterange" data-date-format="yyyy-mm-dd" style="display: inline;">
																<input type="text" id="setTime-endTime" name="example-daterange2" class="form-control" placeholder="终止日期" style="width: 40%;" >
															</div>
													</div>
												</div>
													<div id="quesnote3" class="note" style='color:red;width:fit-content;margin-top: 2%;margin-left: 2.4%;'></div>
											
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="setTime()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
					</div>
					<!-- END Page Content -->
				</div>
				<!-- END Main Container -->
			</div>
			<!-- END Page Container -->
		</div>
		<!-- END Page Wrapper -->

		<!-- jQuery, Bootstrap, jQuery plugins and Custom JS code -->
		<script src="js/vendor/jquery-2.2.4.min.js"></script>
		<script src="js/vendor/bootstrap.min.js"></script>
		<script src="js/plugins.js"></script>
		<script src="js/app.js"></script>
		<script src="js/layui.js"></script>
		<script src="js/layui.all.js"></script>
		<script src="js/lay/modules/laypage.js"></script>
		<!-- Load and execute javascript code used only in this page -->
		<script src="js/pages/uiTables.js"></script>
		<script>
			var id = '',
				text = '',
				total='';
			var ip;
			var getUrl = '/survey/detail',
				getqUrl = '/detail'
				getCatUrl = '/surveyGroup/getGroup2';
			var dataSet,
				checkedSet=[];
			var allsend=[];
			var checked=[];
			var configJson='js/confing.json'
			$(function() {
			$.getJSON(configJson,function(data){
				ip=data.urlip;
				identi()
				time()
				UiTables.init();
				getID();
				getDetail();
				getImportData()
			});
			});
			
			function fresh(){
				$(".layui-laypage-btn").click();
			}
			
			function goto_send(){
				var url='sendmsg.html';
				window.open(url, '_blank');
			}
			function logout(){
				$.ajax({
					type:"get",
					url:ip+"/logout",
					data:{},
					async:true,
					dataType: "json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					 if(!res.code){
      					 	window.location.href="login.html"
      					 }
      				}
				});	
			}
			
			function identi()
			{
				$.ajax({
     				type: "get",
   					url: ip+"/user/type",
  					data:{
  						
  					},
    				async: true,
    				dataType: "json",
     				xhrFields: {withCredentials: true},
    				crossDomain:true,
    				success: function(res) {
    					console.log("sssss")
    					console.log(res)
						if(res.code==-1)
						{
							 window.location.replace("login.html")
							 window.history.forward(1);
						}
    				},
    				async:false
     			});
			}
			
			function getID() {
				url = location.search;
				if(url.indexOf("?") != -1) { //判断是否有参数
					var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串
					strs = str.split("="); //用等号进行分隔 （因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔）
					console.log(strs[1]); //直接弹出第一个参数 （如果有多个参数 还要进行循环的）
					id = strs[1];
				}
			}
			var data;
			function getDetail(){
				$.ajax({
					type: "get",
					url: ip + getUrl,
					data: {
						id: id
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						data=res.data
						getquestion(res.data);
						setData(res.data); 
						if(res.data.surveyGroupId){
							getCat(res.data.surveyGroupId);
							$("#member-type").removeClass("hidden");
							$("#select_opt").removeClass("hidden");
							$("#example-datatable").removeClass("hidden")
							$('#sending_togo').removeClass("hidden");
							$("#input-search-survey").removeClass("hidden")
						}else{
							//导入人员组
							  
							 
						}
						$("#survey-preview").attr("name",res.data.questionsID)
						$("#department").html(res.data.section)
						$("title").html("调查详情——"+res.data.title)
					},
					async: true
				});
			}
			
			function copyUrl(){
				//var urld = $("#survey-url").val;
 				var Url2=document.getElementById("survey-url").innerText;
        		var oInput = document.createElement('input');
      			oInput.value = Url2;
        		document.body.appendChild(oInput);
        		oInput.select(); // 选择对象
        		document.execCommand("Copy"); // 执行浏览器复制命令
       	 		oInput.className = 'oInput';
        		oInput.style.display='none';
        		alert('复制成功');
			}
			
			function preview(quesId) {
				var url='checkQuestionnaire.html?id='+quesId;
				window.open(url, '_blank');
			}
			
			//添加人员小组并显示信息==========================================================
			
			//surveyGroup得到资产小组等各种小组，没分页
			function getImportData() {
				var getDataUrl = '/surveyGroup';

				$.ajax({
					type: "get",
					url: ip + getDataUrl,
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							dataSet1 = res.data;
							if($('#import-datatable').hasClass('dataTable')) {
									var oldTable = $('#import-datatable').dataTable();
									oldTable.fnClearTable(); //清空一下table
									oldTable.fnDestroy(); //还原初始化了的dataTable
									$('#import-datatable').empty();
							}
							//填充数据到modal中
							setTable1();
						}
					},
					
					async: true
				});
				//$("#modal-import").modal("toggle");
			}
			
			function getImport(){
				$("#modal-import").modal("toggle");
			}
			
			//动态填充modol表格 datatable============================
			function setTable1() {
				$('#import-datatable').dataTable({
					data: dataSet1,
					columns: [{
						title: '选择',
						//						width: '30px',
						className: 'text-center',
						data: null,
						render: function(data, type, full, meta) {
							var content = '<label class="csscheckbox csscheckbox-primary">';
							content += '<input id="example1" type="radio" name="example1" value="' + data.id + '"/>';
							content += '<span></span>';
							content += '</label>';
							return content;
						}
					}, {
						title: '调查小组',
						className: 'text-center',
						data: 'groupName'
					}],
					aoColumnDefs: [{
						orderable: false,
						targets: [0, 1]
					}],
					pageLength: 5,
					lengthMenu: [
						[5, 10, 20],
						[5, 10, 20]
					]
				});
				//复选框===点击按钮获得选择小组的id，将其赋给全局groupName
				$('#import-datatable').on("change", ":radio", function() {
					// 一般复选
					console.log($(this).val());
					var checkedId = $(this).val();
					$.each(dataSet1, function(index, value) {
						if(value.id == checkedId) {
							surveyGroupId= value.id;
							$("#detail_number").attr("name",surveyGroupId)
							console.log(surveyGroupId)
						}
					});
				});
			}
			//===================================================
			//绑定人员和调查
			function bindPeople() {
				var bindUrl = '/survey/userList';

				$.ajax({
					type: "put",
					url: ip+ bindUrl,
					data: {
						"id":id,
						"surveyGroupId":surveyGroupId,
					},
					dataType: "json",
					//contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						if(res.code == 0) {
							getCat(surveyGroupId);
						}else{
							$("#modal-import").addClass("hidden")
							$("#fail_msg").html("当前调查组已绑定调查,"+res.msg);
							$("#modal-bindpeople").modal("toggle")
						}
					},
					async: true
				});
			}
			
			 $("#modal-bindpeople").on("hide.bs.modal",function(){
				console.log("hhhhh")
				$("#modal-import").removeClass("hidden")
			});
			//========================================================================
			
			
			function getquestion(date){
				$.ajax({
					type: "get",
					url: ip + getqUrl,
					data: {
						id: date.questionsID
					},
					dataType: "json",
					//contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						$("#survey-title").html(res.data[0]);
						$("#survey-title").attr("href","checkQuestionnaire.html?id="+date.questionsID)
					},
					async: true
				});
			}
			var retotal;
			function getAllMember(pageconf,group) {
				if(!pageconf){
					pageconf={};
					pageconf.pageSize=8;
					pageconf.currentPage=1;
				}	
				$.ajax({
					type: "get",
					url: ip + '/surveyGroup/getUsers2',
					data: {
						surveyId: id,
						group: group,
						page:pageconf.currentPage,
						size:pageconf.pageSize,
						keyWord:$("#input-search-survey").val()
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						if(res.code == 0) {
							$.each(res.data.datas, function(index, value) {
								value.informed=value.informed;
							});
							dataSet=res.data.datas;
							if(!retotal){
							retotal=res.data.total;
							}
							total=res.data.total;
							getPage(pageconf,dataSet,group)
						}
						
					},
					async: true
				});
			}
			
			$('#input-search-survey').bind('input propertychange', function() {
    			getAllMember('',$("#val-surveybinding").val())
  			});
			function getallsendid(){
				$.ajax({
					type: "get",
					url: ip + '/surveyGroup/getUsers2',
					data: {
						"surveyId": id,
						"group":$("#val-surveybinding").val(),
						"keyWord":$("#input-search-survey").val(),
						"page":1,
						"size":retotal,
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						if(res.code == 0) {
							allsend=[];
							console.log(allsend)
							$.each(res.data.datas, function(index, value) {
								 allsend.push(value.id);
							});
							console.log(allsend)
							checkedSet=allsend;
						}
					},
					async:false
				});
			}
			var curpage=1;
			function getPage(pageconf,date,type){
				layui.use(['laypage','layer'],function(){
					var laypage=layui.laypage;
						
					laypage.render({
						elem:'layui',
						count:total,
						skin:'#7c62ad',
						curr:pageconf.currentPage,
						limit:pageconf.pageSize,
						skip:true,
						first:"首页",
						last:"尾页",
						layout:['count','skip', 'next', 'prev'],
						jump:function(obj,first){
							page=obj.curr;
							limit=obj.limit;
							if(!first){
								 pageconf.currentPage=obj.curr;
								 curpage=pageconf.currentPage;
								 pageconf.pageSize=obj.limit;
								 getAllMember(pageconf,type,);
							}
						}
						 
						
					});
					fillTable(date,(pageconf.currentPage-1)*pageconf.pageSize,pageconf.currentPage);
				});
			}
		
			function fillTable(date,num,currentpage){
				var info='';
				if(!checked[currentpage]){
					checked[currentpage]=[];
				if($('#clickall').is(':checked')) {
					for(var i=0;i<9;i++)
					{
						checked[currentpage][i]=true;
					}
				}else{
					for(var i=0;i<9;i++)
					{
						checked[currentpage][i]=false;
					}
				}
				}
				$.each(date, function(index,obj) {
					var i=index;
					index=index+num+1;
					info += "<tr class='column center'><td class='column' style=' text-align: center; '>"+"<input style='width: 20px;height: 20px;'  id="+i+" name='addcheck' type='checkbox'"+(checked[currentpage][i]? "checked   ":" ") +"value='" + obj.id + "'/>"+"</td><td class='column'>" + obj.username + "</td><td class='column'>" + obj.name + "</td><td class='column'>"+obj.collegeName+"</td><td class='column'>"+obj.longPhone+"</td><td class='column'>"+obj.userType+"</td><td class='column'>"+obj.finished+"</td><td class='column'>"+obj.informed+"</td></tr>"; 
				});	
				$("#tab_list").html(info);
			}
			
			function getCat(surveyGroupId) {
				$.ajax({
					type: "get",
					url: ip + getCatUrl,
					data: {
						surveyGroupId: surveyGroupId
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							setMember(res.data);
							$("#import-close").click();
							$("#member_num").html("<span style='padding: 17px;display: inline;'>调查人员</span>"+"<span style='padding: 5px 20px;border-radius: 15px;background: #2c7e8cb5;color: white;' class='btn btn-effect-ripple btn-danger'>"+res.data.surveyGroupName +"</span>"+"<button type='button' class='btn btn-effect-ripple btn-primary' onclick='deletemember()' style='margin-left: 85%;font-size: .7px;margin:.1% 0;float: right;display: inline;'>清空</button>"+"<button type='button' class='btn btn-effect-ripple btn-primary'onclick='changemember(this.name)' style='float: right;margin: .1% 1% 0 0;border-color: #4d7d98;background: #4d7d98;' name='"+res.data.surveyGroupId+"'>补充人员</button>")
							//加入调查人员所选部门
							
						}
						
//						setData(res.data);
					},
					async: false
				});
			}
			
			function changemember(gid){
				console.log(gid)
				var url = "changeMember.html?gid=" + gid+"?id="+id;
				window.open(url, '_blank');
			}
			
			var currentdate=''
			function time(){
				var date = new Date();
        		var seperator1 = "-";
       		 	var year = date.getFullYear();
       			var month = date.getMonth() + 1;
        		var strDate = date.getDate();
      			if (month >= 1 && month <= 9) {
            		month = "0" + month;
       			 }
     			if (strDate >= 0 && strDate <= 9) {
           			 strDate = "0" + strDate;
       			 }
      			currentdate = year + seperator1 + month + seperator1 + strDate;
			}
			
			function setData(data) {
				$("#survey-name").html(data.title);
				$("#survey-title").html(data.title);
				$("#survey-url").html(data.url);
				var status='';
				if(data.state == "running") {
					status = "运行中";
					chgbtn = '<button class="btn btn-warning" style="width: 80px;" onclick="chgState()">暂停</button>';
					$("#setTime-startTime").val(data.startTime)
					$('#setTime-startTime').attr("disabled",true);
				} else if(data.state == "paused") {
					status = "暂停中";
					chgbtn = '<button class="btn btn-success" style="width: 80px;" onclick="chgState()">运行</button>';
					$("#setTime-startTime").val(data.startTime)
					$('#setTime-startTime').attr("disabled",true);
				} else if(data.state == "notStarted") {
					status = "未开始";
					chgbtn = '<a href="#modal-notStart" data-toggle="modal" class="btn btn-success" style="width: 80px;" >运行</a>';
					$("#setTime-startTime").val(currentdate);
					$("#notStart-startTime").val(currentdate)
				} else if(data.state == "ended") {
					status = "已结束";
					chgbtn = '<a href="#modal-ended" data-toggle="modal" class="btn btn-success" style="width: 80px;" >运行</a>';
					$("#setTime-startTime").val(data.startTime)
					$("#ended-startTime").val(data.startTime)
					$('#setTime-startTime').attr("disabled",true);
					$('#ended-startTime').attr("disabled",true);
				}
				$("#survey-state").html(status);
				$("#btn-outer").html(chgbtn);
				
				var period="周期："+data.startTime+"~"+data.endTime;
				$("#survey-period").html(period);
			}
			
			function setMember(data) {
				$("#member-type").removeClass("hidden");
				$("#select_opt").removeClass("hidden");
				$("#example-datatable").removeClass("hidden");
				$("#sending_togo").removeClass("hidden");
				$("#input-search-survey").removeClass("hidden")
				
				var memStr='',
					optStr='<option value="">所有人员</option>';
				for(one in data.group) {
					memStr=memStr+'<p class="well well-sm">'+ one +'（'+ data.group[one] +'人）</p>'
					optStr=optStr+'<option value="'+one+'">'+one+'</option>';
				}
				$("#member-type").html(memStr);
				$("#val-surveybinding").html(optStr);
				surveyGroupId=data.surveyGroupId;
				getAllMember('','');
			}
			
			
			
			$("#val-surveybinding").on('change', function() {
				getAllMember('',$(this).val());
				getallsendid();
			});
			
			function getCatMember(name) {
				$.ajax({
					type: "get",
					url: ip1 + '/surveyGroup/getUsers',
					data: {
						surveyGroupId: surveyGroupId,
						group: name
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						
					},
					async: true
				});
			}
			function titlenull(){
				$(".null").remove()
				str="<div id='quesnote' class='null' style='margin-left:1%;margin-top:2%;color:red'>*输入名称不能为空</div>"
				var title=	$("#newTitle").val();
				if(!title){
					if(!document.getElementById('quesnote')){
						$(".modal-body").append(str)
					}
				}else{
					if(document.getElementById('quesnote')){
						$(".null").remove()
					}
				}
			}
			//修改名称
			function submit() {
				if(!$("#newTitle").val()){
					 	$("#quesnote").html("*输入名称不能为空")
				}else{
				$.ajax({
					type: "put",
					url: ip+"/survey/rename",
					data: {
						id: id,
						title: $("#newTitle").val()
					},
					dataType: "json",
//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if((!res.code)&&typeof res.data=="string")
						{
							$("#quesnote").html(res.data);
							
						}else{
							$("#survey-name").html($("#newTitle").val())
							$("#modal-chgTitle").click()
						}
					},
					async: true
				});
				}
			}
			
			var chgStateUrl='/survey/setTime';
			
			//未开始
			function chgState1() {
				//				console.log(id);
				$.ajax({
					type: "put",
					url: ip + chgStateUrl,
					data: {
						id: id,
						startTime: $("#notStart-startTime").val(),
						endTime: $("#notStart-endTime").val()
					},
					dataType: "json",
					//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							//先更改周期再更改状态
							$("#modal-notStart").modal("toggle")
							$(".layui-laypage-btn").click();
						}else{
							$("#quesnote1").html(res.msg)
						}
					},
					async: true
				});
			}

			//已结束
			function chgState2() {
				$.ajax({
					type: "put",
					url: ip + chgStateUrl,
					data: {
						id: id,
						startTime: $("#ended-startTime").val(),
						endTime: $("#ended-endTime").val()
					},
					dataType: "json",
					//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							//先更改周期再更改状态
							$("#modal-ended").modal("toggle")
							$(".layui-laypage-btn").click();
						}else{
							$("#quesnote2").html(res.msg)
						}
					},
					async: true
				});
			}

			function setTime() {
				$.ajax({
					type: "put",
					url: ip + chgStateUrl,
					data: {
						id: id,
						startTime: $("#setTime-startTime").val(),
						endTime: $("#setTime-endTime").val()
					},
					dataType: "json",
					//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						//location.reload();
						 if(!res.code){
						 	chgState()
						 }else{
						 	$("#quesnote3").html(res.msg)
						 }
					},
					async: true
				});
			}
			function chgState() {
				console.log(id);
				$.ajax({
					type: "put",
					url: ip +'/survey/changeStates' ,
					data: {
						id: id
					},
					dataType: "json",
					//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						location.reload();
					},
					async: true
				});
			}
			
			var deleteUrl = '/survey/delete';
			
			function deleteSurvey() {
				deleteUrl = deleteUrl + "?id=" + id;

				$.ajax({
					type: "delete",
					url: ip + deleteUrl,
					//					data: {
					//						id: deleteId
					//					},
					dataType: "json",
					//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							window.close();
						}
					},
					async: true
				});
			}
			
			 
			
			//全选
			$("#clickall").on('click',function(){
				if(this.checked){
					checkedSet=[];
					$(this).attr('checked','checked')
					$("input[name='addcheck']").each(function(){
						this.checked=true;
					});
					getallsendid();
					for(var i=1;i<=curpage;i++)
					{
						for(var j=0;j<9;j++)
						{
							checked[i][j]=true;
						}
					}
				}else{
					$(this).removeAttr('checked')
					$("input[name='addcheck']").each(function(){
						this.checked=false;
					});
					checkedSet=[];
					for(var i=1;i<=curpage;i++)
					{
						for(var j=0;j<9;j++)
						{
							checked[i][j]=false;
						}
					}
				}
			});
			
			/*复选框*/
			$('#example-datatable').on("change", ":checkbox", function() {
				console.log($(this));
				if($(this).is(':checked')) {
					if($(this).val().length>=7){
					checkedSet.push($(this).val());
					var num=parseInt(this.id); 
					checked[curpage][num]=true;
					}
				} else {
					var index = checkedSet.indexOf($(this).val());
					if(index > -1) {
						checkedSet.splice(index, 1);
					}
					console.log(index)
					var num=parseInt(this.id); 
					console.log(num)
					checked[curpage][num]=false;
				}
				console.log(checkedSet);
			});
			
			function sendMsg() {
				$.ajax({
					type: "post",
					url: ip + '/url/send',
					data: JSON.stringify({
						id: id,
						list: checkedSet
					}),
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							//location.reload();
						}
						
					},
					async: true
				});
			}
			
			function sendgoto() {
				$.ajax({
					type: "post",
					url: ip + '/url/addPool',
					data: JSON.stringify({
						id: id,
						list: checkedSet
					}),
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							$("#modal-sendmsg").modal("toggle");
							
						}
						
					},
					async: true
				});
			}
			
			
			
			///=====清空人员组===============================
			function deletemember(){
				$("#modal-note").modal("toggle")
			}
			function deletemember2(){
				 $.ajax({
					type: "post",
					url: ip + '/survey/deleteUserList',
					data: {
						id: id,
					},
					//dataType: "json",
					//contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							if(res.data=="人员列表删除成功"){
								location.reload();
							}else{
								$("#modal-note").modal("toggle")
								$("#modal-fnote").modal("toggle")
								$("#deletenode").html(res.data)
							}
						}else{
							
						}
						
					},
					async: true
				});
			}
		</script>

	</body>

</html>